/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package multicastclient;

import java.io.*;
import java.net.*;
public class MulticastClient {
    public static void main(String[] args) throws IOException {
      MulticastSocket socket = new MulticastSocket(2345);
	//InetAddress address = InetAddress.getByName("224.0.0.100");
	//socket.joinGroup(address);
        socket.joinGroup(InetAddress.getByName("224.0.0.100"));
        
	byte[] buf = new byte[256];
	DatagramPacket packet;

	while(true) {
	   packet = new DatagramPacket(buf, buf.length);
	   socket.receive(packet);

	   String received = new String(packet.getData(), 0, packet.getLength());
	   System.out.println("Received: " + received);
	    try {
		   Thread.currentThread().sleep(0); 
            }
		catch (InterruptedException e) {
                }
       }
}
}
